﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PhotoGallery.Core.Business.Role>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    修改角色 - 重庆公安局图片管理系统
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="con-box">
        <div class="head">
            <h2>
                <%= Html.ActionLink("角色管理", "Index") %>
                &gt; 修改角色
            </h2>
        </div>
        <div class="con">
            <div class="box">
                <% using (Html.BeginForm("Update", "Role", FormMethod.Post, new { id = "mainForm" }))
                   {%>
                <%: Html.HiddenFor(model=>model.Id) %>
                <p>
                    <label class="i" for="Name">
                        名称：
                    </label>
                    <%= Html.TextBoxFor(model => model.Name, new { @class = "text w200", title = "必填项，30字以内", required = "required", maxlength = "30" })%>
                    <label id="Name-Info">
                    </label>
                </p>
                <p>
                    <label class="i" for="Status">
                        状态：
                    </label>
                    <select name="Status" class="text w200">
                        <option value="0">正常</option>
                        <option value="1">不使用</option>
                    </select>
                </p>
                <p>
                    <label class="i" for="Operation">
                        描述：
                    </label>
                    <%= Html.TextAreaFor(model => model.Description, new { @class = "text w200", title = "必填项，50字以内", required = "required", maxlength = "50" })%>
                </p>
                <div class="action paddingl90">
                    <span class="sexybutton" id="btn-submit"><span><span>
                        <input type="submit" class="save" value="保存" /></span></span></span>
                </div>
                <% } %>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#mainForm input[type='text']").tooltip({
                position: "center right",
                offset: [-2, 5],
                effect: "fade",
                opacity: 0.7
            });

            $("#mainForm").validator({ lang: 'zh-CN' });
            var prevname = $("#Name").val();
            window.console && console.log(prevname);
            (function () {
                var prev = '', c, reg, url = '<%= Url.Action("CheckRoleName", "Role") %>';

                $("#Name").change(function () {
                    if ($(this).val() === prevname)
                    { window.console && console.log(prevname); return; }

                    $.post(url, { name: $("#Name").val() }, function (data) {
                        if (data.success) {
                            //$("#btn-submit").removeClass("disabled").find(":submit").attr("disabled", "");
                            $("#Name-Info").html(data.message).removeClass('error').addClass("green");
                        } else {
                            //$("#btn-submit").addClass("disabled").find(":submit").attr("disabled", "disabled");
                            $("#Name-Info").html(data.message).removeClass('greed').addClass("error");
                        }
                    });

                });
            })();
        });
    </script>
</asp:Content>
